Skip to content

Reject legend_loc='on data' loudly in pl.show()#649

Merged
timtreis merged 2 commits intomainfrom
fix/issue-624-legend-on-data
May 8, 2026
Merged

Reject legend_loc='on data' loudly in pl.show()#649
timtreis merged 2 commits intomainfrom
fix/issue-624-legend-on-data

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 8, 2026

Summary

  • Closes legend_loc='on data' crashes with misleading ValueError for shapes, points, labels #624
  • legend_loc="on data" is meaningless in spatialdata-plot — there are no scatter embedding coordinates for shapes, points, labels, or image channels. It previously crashed deep in scanpy with ValueError: Grouper and axis must be same length (categorical path) or warned and fell back (channel-legend path).
  • pl.show() now raises a clear ValueError at the API surface, after the legend_params dict override resolves the final legend_loc, so all entry paths are covered.
  • The now-dead warn-and-fallback in _draw_channel_legend is removed.

timtreis added 2 commits May 8, 2026 16:34
Closes #624. 'on data' requires scatter embedding coordinates, which do not
exist for any spatialdata-plot render type. Previously crashed deep in scanpy
with 'Grouper and axis must be same length' (categorical) or warned and fell
back (channel legend). Now raises a clear ValueError at the API surface and
the obsolete channel-legend fallback is removed.
@timtreis timtreis merged commit 5e6f3a9 into main May 8, 2026
6 of 7 checks passed
@timtreis timtreis deleted the fix/issue-624-legend-on-data branch May 8, 2026 14:40
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.88%. Comparing base (9be9156) to head (e9d9972).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/spatialdata_plot/pl/basic.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
+ Coverage   76.86%   76.88%   +0.02%     
==========================================
  Files          11       11              
  Lines        3276     3275       -1     
  Branches      773      773              
==========================================
  Hits         2518     2518              
+ Misses        458      457       -1     
  Partials      300      300              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 86.80% <ø> (+0.38%) ⬆️
src/spatialdata_plot/pl/basic.py 85.41% <0.00%> (-0.53%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

legend_loc='on data' crashes with misleading ValueError for shapes, points, labels

2 participants